package com.beiing.tianshuai.tianshuai.home.presenter;

import com.beiing.tianshuai.tianshuai.dongtai.CallBack;
import com.beiing.tianshuai.tianshuai.entity.HomeBean;
import com.beiing.tianshuai.tianshuai.home.model.HomeModelImpl;
import com.beiing.tianshuai.tianshuai.home.model.IHomeModel;
import com.beiing.tianshuai.tianshuai.home.view.IHomeView;

/**
 * Created by LZQ on 2017/11/16.
 */

public class HomePresenterImpl implements IHomePresenter {

    private IHomeView mView;
    private IHomeModel mModel;

    public HomePresenterImpl(IHomeView mView) {
        this.mView = mView;
        this.mModel = new HomeModelImpl();
    }

    @Override
    public void getHomeContent(String uid) {
        mModel.getHomeContent(uid, new CallBack<HomeBean>() {

            @Override
            public void result(HomeBean bean) {
                mView.showHomeContent(bean);
            }

            @Override
            public void error(Throwable e) {
                mView.requestHomeContentFailed();
            }
        });
    }

    @Override
    public void getHomeList(int page) {
        mModel.getHomeList(page, new CallBack<HomeBean>() {

            @Override
            public void result(HomeBean bean) {
                mView.showHomeList(bean);
            }

            @Override
            public void error(Throwable e) {
                mView.requestFailed();
            }
        });
    }
}
